﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="add_player.aspx.cs" Inherits="SQT.tracnghiem.Ajax.ASP.Events.add_player" %>

<%@ Import Namespace="DataAccess" %>
<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<body>
    <%
        string player = Request.QueryString["player"];
        var get_player = new TblUserController().FetchAll().Where(x => x.UserLevel == 6);
    %>
    <div style="width: 80%" class="w3-modal-content w3-animate-top w3-card-8 w3-display-container">
        <header class="w3-center w3-padding w3-large w3-teal">Thêm người chơi</header>
        <div class="w3-row w3-padding w3-half" style="height: 350px; overflow: auto">
            <table class="volca-table w3-table w3-striped w3-bordered w3-white">
                <tbody id="tbl_add_player_form">
                    <tr class="w3-teal" style="width: 100%">
                        <td>&nbsp;</td>
                        <td>Người chơi chưa thêm</td>
                        <td>&nbsp;</td>
                    </tr>
                    <tr class="w3-teal">
                        <td>Hình ảnh</td>
                        <td>Tên đăng nhập</td>
                        <td>Tên đội</td>
                    </tr>
                    <%if (player != "")
                        {
                            string[] split = player.Split(',');%>
                    <%foreach (TblUser user in get_player)
                        {
                            if (this.check_player(split, user.UserId)==false)
                            { 
                    %>
                    <tr onclick="add_player(this.id)" id="add_player_<%=user.UserId %>">
                        <td class="w3-hide"><%=user.UserId %></td>
                        <td style="padding: 0.8% 0.5%">
                            <img src="../Content/avatar/<%=user.Avatar %>" style="width: 50px; height: 50px" class="w3-circle" /></td>
                        <td style="padding: 0.8% 0.5%"><%=user.UserName %></td>
                        <td style="padding: 0.8% 0.5%"><%=user.FullName %></td>
                    </tr>
                    <%}}
                        }
                        else
                        { %>
                    <%foreach (TblUser user in get_player)
                        {
                    %>
                    <tr onclick="add_player(this.id)" id="add_player_<%=user.UserId %>">
                        <td class="w3-hide"><%=user.UserId %></td>
                        <td style="padding: 0.8% 0.5%">
                            <img src="../Content/avatar/<%=user.Avatar %>" style="width: 50px; height: 50px" class="w3-circle" /></td>
                        <td style="padding: 0.8% 0.5%"><%=user.UserName %></td>
                        <td style="padding: 0.8% 0.5%"><%=user.FullName %></td>
                    </tr>
                    <%}
                        } %>
                </tbody>
            </table>
        </div>
        <div class="w3-row w3-padding w3-half" style="height: 350px; overflow: auto">
            <table class="volca-table w3-table w3-striped w3-bordered w3-white">
                <tbody id="tbl_added_player_form" class="w3-row">
                    <tr class="w3-teal" style="width: 100%">
                        <td></td>
                        <td>Người chơi đã thêm</td>
                        <td></td>
                        <td></td>
                    </tr>
                    <tr class="w3-teal">
                        <td>Hình ảnh</td>
                        <td>Tên đăng nhập</td>
                        <td>Tên đội</td>
                        <td>Hủy</td>
                    </tr>
                    <%if (player != "")
                        {
                            string[] split = player.Split(',');
                            for (int i = 0; i < split.Length-1; i++)
                            {
                                var get_player_added = new TblUserController().FetchAll().Single(x => x.UserId == int.Parse(split[i]));
                    %>
                    <tr id="add_player_<%=get_player_added.UserId %>" class="w3-row chosen-player">
                        <td class="w3-hide"><%=get_player_added.UserId %></td>
                        <td style="padding: 0.8% 0.5%">
                            <img src="../Content/avatar/<%=get_player_added.Avatar %>" style="width: 50px; height: 50px" class="w3-circle" /></td>
                        <td style="padding: 0.8% 0.5%"><%=get_player_added.UserName %></td>
                        <td style="padding: 0.8% 0.5%"><%=get_player_added.FullName %></td>
                        <td class="w3-col l1"><i onclick="cancel_add_player(this.parentElement.parentElement.id)" class="fa fa-trash"></i></td>
                    </tr>
                    <%}
                        } %>
                </tbody>
            </table>
        </div>
        <div class="w3-row w3-padding w3-center">
            <a onclick="btn_add_chosen_player()" class="w3-btn w3-teal"><i class="fa fa-save"></i>&nbsp;Lưu</a>
            <a onclick="$('#add_player_modal').fadeOut()" class="w3-btn w3-teal"><i class="fa fa-times"></i>&nbsp;Huỷ</a>
        </div>
    </div>
</body>
</html>
